package org.example;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * ClassName: WuDaAspect
 * Package: org.example
 * Description: 演示环绕通知
 *
 * @Author wanghao
 * @Create 2024-07-08 9:59
 * @Version 1.0
 */
//@Component
@Aspect
public class WuDaAspect5 {
    @Around(value = "org.example.MyPointCut.myPointCut()")
    public void song(ProceedingJoinPoint joinPoint) {
        try {
            // 此处相当于@Before - 前置增强
            System.out.println("before");
            Object returnObj = joinPoint.proceed(joinPoint.getArgs());
            // 此处相当于@AfterReturning - 后置返回增强
            System.out.println("after returning");
        } catch (Throwable e) {
            e.printStackTrace();
            // 此处相当于@AfterThrowing - 后置异常增强
            System.out.println("after throwing");
        } finally {
            // 此处相当于@After - 后置增强
            System.out.println("after");
        }
    }

}
